//
//  PlaceOrderTableViewCell.m
//  AmountBody
//
//  Created by smm on 2017/12/25.
//  Copyright © 2017年 RCMTM. All rights reserved.
//

#import "PlaceOrderTableViewCell.h"
#import "EssentialModel.h"
#import "ShoppingCollectionModel.h"
#import "SpecialView.h"
#import "PlaceOrderSpecialModel.h"
#import "CustomRulerNewsView.h"
#import "PlaceOrderViewController.h"
#import <AmountBody-Swift.h>
CGFloat const ChooseText_Tag = 1200000;
CGFloat const ChooseButton_Tag = 1300000;
static const CGFloat Text_Tag = 1400000;
static const CGFloat View_Tag = 402000;
static const CGFloat Cell_H = 360;

@implementation PlaceOrderTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)setCellWithModel:(PlaceOrderModel*)model
{
    CGFloat jianGeW = 20;
    CGFloat top = 60; // 顶端盖高度
    CGFloat bottom = 20 ; // 底端盖高度
    CGFloat left = 100; // 左端盖宽度
    CGFloat right = 20; // 右端盖宽度
    _backImage.frame = CGRectMake(jianGeW, 0, SCREEN_W-jianGeW*2, model.cell_H);
    _backImage.userInteractionEnabled = YES;
    UIImage * image = [UIImage imageNamed:@"s_back"];
    // 指定为拉伸模式，伸缩后重新赋值
    image = [image stretchImageWithInsetsTop:top left:left bottom:bottom right:right];
    _backImage.image = image;
    _backView.frame = CGRectMake(jianGeW, 40, SCREEN_W-jianGeW*4,model.cell_H-top);
    [_backImage addSubview:_backView];
    _cellH = model.cell_H;
    _model = model;
    
    switch (_type) {
        case PlaceOrderTypeForProductsNews:
        {
            layoutViews(^{
                [self loadUIForProductsNews:model];
            }, ^{
                [self loadUIForProductsNewsForVertical:model];
            });
            
        }
            break;
        case PlaceOrderTypeForTechnologyNews:
        {
            [self loadUIForTechnologyNews:model];
        }
            break;
        case PlaceOrderTypeForCustomerNews:
        {
            layoutViews(^{
                [self loadUIForCustomerNews:model];
            }, ^{
                [self loadUIForCustomerNewsForVertical:model];
            });
        }
            break;
        case PlaceOrderTypeForAmountNews:
        {
            [self loadUIForAmountNews:model];
        }
            break;
        default:
            break;
    }
}
#pragma mark -- 产品信息竖屏适配
//产品信息竖屏
-(void)loadUIForProductsNewsForVertical:(PlaceOrderModel*)model
{
    for (UIView * view in _backView.subviews) {
        [view removeFromSuperview];
    }
    CGFloat jianGeW = 20;
    CGFloat jianGeH = 20;
    CGFloat b_viewH = _backView.frame.size.height;
    CGFloat b_viewW = _backView.frame.size.width;
    CGFloat viewW = (b_viewW-jianGeW*3)/2.0;
    CGFloat viewH = (b_viewH-jianGeH)/3.0;
    CGFloat labelH = 30;
    CGFloat imageW = 15;
    CGFloat imageH = imageW;
    CGFloat h_imageW = 35;
    CGFloat h_imageH = 31;
    UIImageView * headImage = [[UIImageView alloc]initWithFrame:CGRectMake(b_viewW-jianGeW-h_imageW, 0, h_imageW, h_imageH)];
    headImage.image = [UIImage imageNamed:@"s_yifu"];
    [_backView addSubview:headImage];
    NSArray * nameArray = [NSArray arrayWithObjects:@"产品：",@"产品：",@"面料编号：",@"面料类型：",@"客户单号：",@"订单数量：", nil];
    NSArray * valueArray = [NSArray arrayWithObjects:@"产品：value",@"产品：value",@"面料编号：value",@"面料类型：value",@"客户单号：value",@"订单数量：value", nil];
    NSMutableArray * needArr = [[NSMutableArray alloc]init];
    for (int i=0; i<nameArray.count; i++) {
        PlaceOrderTypeModel * l_model = [[PlaceOrderTypeModel alloc]init];
        l_model.name = [nameArray objectAtIndex:i];
        l_model.value = [valueArray objectAtIndex:i];
        l_model.selectArr = [[NSMutableArray alloc]init];
        if ( i==0 || i==3) {
            l_model.needSelect = YES;
            for (int k = 0; k<4; k++) {
                TypeModel* t_model = [[TypeModel alloc]init];
                t_model.name = [NSString stringWithFormat:@"%@%d",l_model.name,k];
                [l_model.selectArr addObject:t_model];
            }
            if (i==0) {
                
                l_model.chooseType = PickerChooseTypeForProduct;
            }else{
                l_model.chooseType = PickerChooseTypeForFabric;
            }
            
        }else{
            l_model.needSelect = NO;
        }
        
        [needArr addObject:l_model];
    }
    _needArray = [NSArray arrayWithArray:needArr];
    for (int i=0; i<needArr.count; i++) {
        PlaceOrderTypeModel * n_model = [needArr objectAtIndex:i];
        int k = i/2;
        int j = i%2;
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(jianGeW+(viewW+jianGeW)*j, (viewH+5)*k, viewW, viewH)];
        
        UILabel * label = [[UILabel alloc]init];
        label.text = n_model.name;
        label.textColor = ZhongZi_Color;
        label.font = Cell_Medium_Font;
        [label sizeToFit];
        label.frame = CGRectMake(0, (viewH-labelH)/2.0, label.frame.size.width, labelH);
        [view addSubview:label];
        if (n_model.needSelect) {
            imageW = 15;
            UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(viewW-imageW, (viewH-imageH)/2.0, imageW, imageH)];
            image.image = [UIImage imageNamed:@"ytj_xiaBiao"];
            [view addSubview:image];
        }else{
            imageW = 0;
        }
        UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width, (viewH-labelH)/2.0, viewW-(label.frame.origin.x+label.frame.size.width)-imageW-5, labelH)];
        text.text = n_model.value;
        text.textColor = ShenZi_Color;
        text.font = Cell_Medium_Font;
        text.delegate = self;
        text.textAlignment = NSTextAlignmentRight;
        text.tag = Text_Tag+_type*10+i;
        text.userInteractionEnabled = YES;
        text.returnKeyType = UIReturnKeyNext;
        [view addSubview:text];
        if (n_model.needSelect) {
            
            text.userInteractionEnabled = NO;
            text.tag = ChooseText_Tag+n_model.chooseType;
            UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width, (viewH-labelH)/2.0, viewW-(label.frame.origin.x+label.frame.size.width), labelH)];
            button.tag = ChooseButton_Tag+n_model.chooseType;
            [button addTarget:self action:@selector(selectFunc:) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:button];
        }
        
        UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, viewH-1, viewW, 1)];
        lineView.backgroundColor = Line_color;
        [view addSubview:lineView];
        [_backView addSubview:view];
        if (i==0) {
            i++;
        }
    }
}
#pragma mark -- 产品信息
//产品信息
-(void)loadUIForProductsNews:(PlaceOrderModel*)model
{
    for (UIView * view in _backView.subviews) {
        [view removeFromSuperview];
    }
    CGFloat jianGeW = 20;
    CGFloat jianGeH = 20;
    CGFloat b_viewH = _backView.frame.size.height;
    CGFloat b_viewW = _backView.frame.size.width;
    CGFloat viewW = (b_viewW-jianGeW*4)/3.0;
    CGFloat viewH = (b_viewH-jianGeH)/2.0;
    CGFloat labelH = 30;
    CGFloat imageW = 15;
    CGFloat imageH = imageW;
    CGFloat h_imageW = 35;
    CGFloat h_imageH = 31;
    UIImageView * headImage = [[UIImageView alloc]initWithFrame:CGRectMake(b_viewW-jianGeW-h_imageW, 0, h_imageW, h_imageH)];
    headImage.image = [UIImage imageNamed:@"s_yifu"];
    [_backView addSubview:headImage];
    NSArray * nameArray = [NSArray arrayWithObjects:@"产品：",@"面料类型：",@"产品：",@"面料编号：",@"客户单号：",@"订单数量：", nil];
    NSArray * valueArray = [NSArray arrayWithObjects:@"产品：value",@"面料类型：value",@"产品：value",@"面料编号：value",@"客户单号：value",@"订单数量：value", nil];
    NSMutableArray * needArr = [[NSMutableArray alloc]init];
    for (int i=0; i<nameArray.count; i++) {
        PlaceOrderTypeModel * l_model = [[PlaceOrderTypeModel alloc]init];
        l_model.name = [nameArray objectAtIndex:i];
        l_model.value = [valueArray objectAtIndex:i];
        l_model.selectArr = [[NSMutableArray alloc]init];
        if ( i==0 || i==1) {
            l_model.needSelect = YES;
            for (int k = 0; k<4; k++) {
                TypeModel* t_model = [[TypeModel alloc]init];
                t_model.name = [NSString stringWithFormat:@"%@%d",l_model.name,k];
                [l_model.selectArr addObject:t_model];
            }
            if (i==0) {
                
                l_model.chooseType = PickerChooseTypeForProduct;
            }else{
                l_model.chooseType = PickerChooseTypeForFabric;
            }
            
        }else{
            l_model.needSelect = NO;
        }
        
        [needArr addObject:l_model];
    }
    _needArray = [NSArray arrayWithArray:needArr];
    for (int i=0; i<needArr.count; i++) {
        PlaceOrderTypeModel * n_model = [needArr objectAtIndex:i];
        int k = i/3;
        int j = i%3;
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(jianGeW+(viewW+jianGeW)*j, (viewH+5)*k, viewW, viewH)];
        
        UILabel * label = [[UILabel alloc]init];
        label.text = n_model.name;
        label.textColor = ZhongZi_Color;
        label.font = Cell_Medium_Font;
        [label sizeToFit];
        label.frame = CGRectMake(0, (viewH-labelH)/2.0, label.frame.size.width, labelH);
        [view addSubview:label];
        if (n_model.needSelect) {
            imageW = 15;
            UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(viewW-imageW, (viewH-imageH)/2.0, imageW, imageH)];
            image.image = [UIImage imageNamed:@"ytj_xiaBiao"];
            [view addSubview:image];
        }else{
            imageW = 0;
        }
        UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width, (viewH-labelH)/2.0, viewW-(label.frame.origin.x+label.frame.size.width)-imageW-5, labelH)];
        text.text = n_model.value;
        text.textColor = ShenZi_Color;
        text.font = Cell_Medium_Font;
        text.delegate = self;
        text.textAlignment = NSTextAlignmentRight;
        text.tag = Text_Tag+_type*10+i;
        text.userInteractionEnabled = YES;
        text.returnKeyType = UIReturnKeyNext;
        [view addSubview:text];
        if (n_model.needSelect) {
            
            text.userInteractionEnabled = NO;
            text.tag = ChooseText_Tag+n_model.chooseType;
            UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width, (viewH-labelH)/2.0, viewW-(label.frame.origin.x+label.frame.size.width), labelH)];
            button.tag = ChooseButton_Tag+n_model.chooseType;
            [button addTarget:self action:@selector(selectFunc:) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:button];
        }
        
        UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, viewH-1, viewW, 1)];
        lineView.backgroundColor = Line_color;
        [view addSubview:lineView];
        [_backView addSubview:view];
        if (i==1) {
            i++;
        }
    }
}

CGFloat const L_textTag = 1500000;
#pragma mark -- 工艺信息
-(void)loadUIForTechnologyNews:(PlaceOrderModel*)model
{
    for (UIView * view in _backView.subviews) {
        [view removeFromSuperview];
    }
    __block CGFloat jianGeW = 20;
    CGFloat jianGeH = 20;
    __block CGFloat b_imageW = 105;
    CGFloat b_imageH = 80;
    __block CGFloat b_viewH = _backView.frame.size.height;
    CGFloat b_viewW = _backView.frame.size.width;
    __block CGFloat viewW = (b_viewW-jianGeW*4-b_imageW)/2.0;
    __block CGFloat viewH = b_viewH-jianGeH;
    CGFloat d_imageW = 15;
    CGFloat d_imageH = d_imageW;
    
    layoutViews(^{
        jianGeW = jianGeW;
        viewW = (b_viewW-jianGeW*4-b_imageW)/2.0;
        viewH = viewH;
        
    }, ^{
        viewW = (b_viewW-jianGeW*4-b_imageW);
        jianGeW = jianGeW+b_imageW;
        viewH = b_viewH/5.0*2-jianGeH;
    });
    UIView * leftView = [[UIView alloc]initWithFrame:CGRectMake(jianGeW, 0, viewW, viewH)];
    
    [_backView addSubview:leftView];
    UIView *dianView = [[UIView alloc]initWithFrame:CGRectMake(0, (Nomal_Label_H-d_imageH)/2.0, d_imageW, d_imageH)];
    [dianView setYuanJiaoForRadius:3.0 andMasks:NO];
    dianView.backgroundColor = RGBColorAlpha(44, 44, 44, 1);
    [leftView addSubview:dianView];
    
    CGFloat buttonW = 60;
    CGFloat buttonH = 25;
    UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(dianView.frame.origin.x+dianView.frame.size.width+5, 0, 100, Nomal_Label_H)];
    titleLabel.text = @"工艺选择";
    titleLabel.textColor = ZhongZi_Color;
    titleLabel.font = Cell_Medium_Font;
    [leftView addSubview:titleLabel];
    UITextField * l_text = [[UITextField alloc]initWithFrame:CGRectMake(10, titleLabel.frame.origin.y+titleLabel.frame.size.height+10, viewW-buttonW-10, Nomal_Label_H)];
    l_text.placeholder = @"请输入工艺代码";
    l_text.delegate = self;
    l_text.returnKeyType = UIReturnKeyNext;
    l_text.tag = L_textTag;
    l_text.font = Cell_Medium_Font;
    l_text.textColor =QianZi_color;
    [leftView addSubview:l_text];
    
    UIButton * l_button = [[UIButton alloc]initWithFrame:CGRectMake(viewW-buttonW, titleLabel.frame.origin.y+titleLabel.frame.size.height+5, buttonW, buttonH)];
    [l_button setTitle:@"添加" forState:UIControlStateNormal];
    [l_button setTitleColor:RGBColorAlpha(255, 66, 89, 1) forState:UIControlStateNormal];
//    l_button.backgroundColor = RGBColorAlpha(44, 44, 44, 1);
    l_button.titleLabel.font = Cell_Medium_Font;
    [l_button addTarget:self action:@selector(l_buttonFunc:) forControlEvents:UIControlEventTouchUpInside];
    [l_button setYuanJiaoForRadius:5.0 andMasks:NO];
    [l_button setBianKuangAndColor:RGBColorAlpha(255, 66, 89, 1)];
    [leftView addSubview:l_button];
    
    UIView *l_lineView = [[UIView alloc]initWithFrame:CGRectMake(0, l_button.frame.origin.y+l_button.frame.size.height+3, viewW, 1)];
    l_lineView.backgroundColor  =Line_color;
    [leftView addSubview:l_lineView];
    CGFloat imageW = 25;
    CGFloat imageH = imageW;
    UIScrollView *scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, l_lineView.frame.origin.y+l_lineView.frame.size.height+5, viewW, viewH-(l_lineView.frame.origin.y+l_lineView.frame.size.height+5+jianGeH+imageH))];
    [self loadScrollUIForTechnologyNews:scroll];
    [leftView addSubview:scroll];
    UIImageView * l_diImage = [[UIImageView alloc]initWithFrame:CGRectMake(viewW-imageW-5, viewH-imageH-10, imageW, imageH)];
    l_diImage.image = [UIImage imageNamed:@"s_yuanBiao"];
    UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(b_viewW/2.0, 0, 1, viewH)];
    layoutViews(^{
        lineView.frame = CGRectMake(b_viewW/2.0, 0, 1, viewH);
    }, ^{
        viewH = b_viewH-viewH;
        lineView.frame = CGRectMake(10+b_imageW/2.0, 0, 1, b_viewH-jianGeH);
    });
    [leftView addSubview:l_diImage];
    lineView.backgroundColor = Line_color;
    [_backView addSubview:lineView];
    
    UIImageView * headImage = [[UIImageView alloc]init];
    layoutViews(^{
        headImage.frame = CGRectMake((b_viewW-b_imageW)/2.0, 60, b_imageW, b_imageH);
    }, ^{
        headImage.frame = CGRectMake(10, (b_viewH-b_imageW)/2.0, b_imageW, b_imageH);
    });
    headImage.image = [UIImage imageNamed:@"s_yifuLeft"];
    [_backView addSubview:headImage];
    
    UIView * rightView = [[UIView alloc]initWithFrame:CGRectMake(jianGeW*4-20+viewW+1, 0, viewW, viewH)];
    layoutViews(^{
        rightView.frame = CGRectMake(jianGeW*3+viewW+1+b_imageW, 0, viewW, viewH);
    }, ^{
        rightView.frame = CGRectMake(jianGeW, leftView.size.height+10, viewW, viewH);
    });
    UIView *r_dianView = [[UIView alloc]initWithFrame:CGRectMake(0, (Nomal_Label_H-d_imageH)/2.0, d_imageW, d_imageH)];
    [r_dianView setYuanJiaoForRadius:3.0 andMasks:NO];
    
    r_dianView.backgroundColor = RGBColorAlpha(44, 44, 44, 1);
    [rightView addSubview:r_dianView];
    
    UILabel * r_titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(r_dianView.frame.origin.x+r_dianView.frame.size.width+5, 0, 100, Nomal_Label_H)];
    r_titleLabel.text = @"刺绣选择";
    r_titleLabel.textColor = ZhongZi_Color;
    r_titleLabel.font = Cell_Medium_Font;
    [rightView addSubview:r_titleLabel];
    UIView * newsView = [[UIView alloc]initWithFrame:CGRectMake(0, r_titleLabel.frame.origin.y+r_titleLabel.frame.size.height+10, viewW, viewH-(r_titleLabel.frame.origin.y+r_titleLabel.frame.size.height+5+jianGeH+imageH))];
    [self loadNewsViewUIForTechnologyNews:newsView];
     [rightView addSubview:newsView];
    UIView * contentView = [[UIView alloc]initWithFrame:CGRectMake(0, newsView.frame.origin.y+newsView.frame.size.height, viewW, 35)];
    [rightView addSubview:contentView];
    UILabel *r_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, Nomal_Label_H)];
    r_nameLabel.text = @"内容：";
    r_nameLabel.textColor = ZhongZi_Color;
    r_nameLabel.font = Cell_Medium_Font;
    [r_nameLabel sizeToFit];
    r_nameLabel.frame = CGRectMake(0, (35-Nomal_Label_H)/2.0, r_nameLabel.frame.size.width, Nomal_Label_H);
    
    [contentView addSubview:r_nameLabel];
    
    UITextField * r_text = [[UITextField alloc]initWithFrame:CGRectMake(r_nameLabel.frame.origin.x+r_nameLabel.frame.size.width+10, 0, viewW-buttonW-(r_nameLabel.frame.origin.x+r_nameLabel.frame.size.width+10)-10, 35-1)];
    r_text.placeholder = @"请输入刺绣内容文字";
    r_text.returnKeyType = UIReturnKeyNext;
    r_text.font = Cell_Medium_Font;
    r_text.textColor =QianZi_color;
    [contentView addSubview:r_text];
    
    UIButton * r_button = [[UIButton alloc]initWithFrame:CGRectMake(viewW-buttonW, (35-buttonH)/2.0, buttonW, buttonH)];
    [r_button setTitle:@"添加" forState:UIControlStateNormal];
    [r_button setTitleColor:RGBColorAlpha(255, 66, 89, 1) forState:UIControlStateNormal];
    [r_button addTarget:self action:@selector(r_buttonFunc:) forControlEvents:UIControlEventTouchUpInside];;
//    r_button.backgroundColor = RGBColorAlpha(44, 44, 44, 1);
    r_button.titleLabel.font = Cell_Medium_Font;
    
    [r_button setYuanJiaoForRadius:5.0 andMasks:NO];
    [r_button setBianKuangAndColor:RGBColorAlpha(255, 66, 89, 1)];
    [contentView addSubview:r_button];
    
    UIView *r_lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 34, viewW, 1)];
    r_lineView.backgroundColor  =Line_color;
    [contentView addSubview:r_lineView];
    UIScrollView *r_scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, contentView.frame.origin.y+contentView.frame.size.height+5, viewW, viewH-(contentView.frame.origin.y+contentView.frame.size.height+5+jianGeH+imageH))];
    [self loadScrollUIForTechnologyNews:r_scroll];
    [rightView addSubview:r_scroll];
    UIImageView * r_diImage = [[UIImageView alloc]initWithFrame:CGRectMake(viewW-imageW-5, viewH-imageH-10, imageW, imageH)];
    r_diImage.image = [UIImage imageNamed:@"s_yuanBiao"];
    [rightView addSubview:r_diImage];
    [_backView addSubview:rightView];
    
}
-(void)loadNewsViewUIForTechnologyNews:(UIView*)backView
{
    CGFloat viewW = backView.frame.size.width;
    CGFloat viewH = 35;
    CGFloat imageW = 15;
    CGFloat imageH = imageW;
    NSArray * nameArray = [NSArray arrayWithObjects:@"位置：",@"字体：",@"颜色：", nil];
    NSArray * valueArray = [NSArray arrayWithObjects:@"位置：value",@"字体：value",@"颜色：value", nil];
    NSMutableArray * needArr = [[NSMutableArray alloc]init];
    for (int i=0; i<nameArray.count; i++) {
        PlaceOrderTypeModel * l_model = [[PlaceOrderTypeModel alloc]init];
        l_model.name = [nameArray objectAtIndex:i];
        l_model.value = [valueArray objectAtIndex:i];
        l_model.needSelect = YES;
        l_model.selectArr = [[NSMutableArray alloc]init];
        for (int k = 0; k<4; k++) {
            TypeModel* t_model = [[TypeModel alloc]init];
            t_model.name = [NSString stringWithFormat:@"%@%d",l_model.name,k];
            [l_model.selectArr addObject:t_model];
        }
        if (i==0) {
            l_model.chooseType = PickerChooseTypeForPosition;
        }else if(i==1){
            l_model.chooseType = PickerChooseTypeForTypeface;
        }else{
            l_model.chooseType = PickerChooseTypeForColour;
        }
        
        [needArr addObject:l_model];
        _needArray  = [NSArray arrayWithArray:needArr];
    }
    for (int i=0; i<needArr.count; i++) {
        PlaceOrderTypeModel * n_model = [needArr objectAtIndex:i];
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, viewH*i, viewW, viewH)];
        UILabel * nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, (viewH-Nomal_Label_H)/2.0, 200, Nomal_Label_H)];
        nameLabel.textColor = ZhongZi_Color;
        nameLabel.text = n_model.name;
        nameLabel.font = Cell_Medium_Font;
        [nameLabel sizeToFit];
        nameLabel.frame = CGRectMake(0, (viewH-Nomal_Label_H)/2.0, nameLabel.frame.size.width, Nomal_Label_H);
        [view addSubview:nameLabel];
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, viewH-1, viewW, 1)];
        lineView.backgroundColor = Line_color;
        [view addSubview:lineView];
        UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(nameLabel.frame.origin.x+nameLabel.frame.size.width+5, 0, viewW-(nameLabel.frame.origin.x+nameLabel.frame.size.width+5)-imageW-10,viewH-1)];
        text.font = Cell_Medium_Font;
        text.text = n_model.value;
        text.tag = ChooseText_Tag+n_model.chooseType;
        text.userInteractionEnabled = NO;
        text.delegate = self;
        text.textColor = ShenZi_Color;
        [view addSubview:text];
        UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(nameLabel.frame.origin.x+nameLabel.frame.size.width+5, 0, viewW-(nameLabel.frame.origin.x+nameLabel.frame.size.width+5),viewH-1)];
        button.tag = ChooseButton_Tag+n_model.chooseType;
        [button addTarget:self action:@selector(selectFunc:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:button];
        UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(viewW-imageW, (viewH-imageH)/2.0, imageW, imageH)];
        image.image = [UIImage imageNamed:@"ytj_xiaBiao"];
        [view addSubview:image];
        [backView addSubview:view];
    }
    backView.frame = CGRectMake(0, backView.frame.origin.y, viewW, viewH*3);
    
}
#define labelView_Tag 405000
-(void)loadScrollUIForTechnologyNews:(UIScrollView*)scroll
{
    for (UIView * view in scroll.subviews) {
        [view removeFromSuperview];
    }
    CGFloat viewW = scroll.frame.size.width;
    CGFloat viewH = 30;
    CGFloat jianGeH = 5;
    for (int i=0; i<15; i++) {
        UIView * tmpView = [scroll viewWithTag:labelView_Tag+i-1];
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, tmpView.frame.origin.y+tmpView.frame.size.height+5, viewW, viewH)];
        view.tag = labelView_Tag+i;
        [scroll addSubview:view];
        UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, jianGeH, 2, 15)];
        lineView.backgroundColor = RGBColorAlpha(44, 44, 44, 1);
        [view addSubview:lineView];
        UILabel * textLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, jianGeH, 200, Nomal_Label_H)];
        NSString * str = @"A011 上衣：款式号  ";
        NSString * str2 = @"100bradly22 ";
        NSString * needStr = [NSString stringWithFormat:@"%@%@",str,str2];
        NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:needStr];
        
        
        // 添加下划线
        [attrStr addAttribute:NSUnderlineStyleAttributeName
                        value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
                        range:NSMakeRange(str.length, str2.length)];
//        textLabel.text = @"A011 上衣：款式号 100bradly22 ";
        textLabel.attributedText = attrStr;
        textLabel.textColor = ZhongZi_Color;
        textLabel.font = Cell_Little_Font;
        textLabel.numberOfLines = 0;
        [textLabel sizeToFit];
        textLabel.frame = CGRectMake(10, jianGeH, textLabel.frame.size.width, textLabel.frame.size.height);
        view.frame = CGRectMake(0, tmpView.frame.origin.y+tmpView.frame.size.height+5, viewW, textLabel.frame.size.height+textLabel.frame.origin.y);
        CGFloat buttonW = 30;
        CGFloat buttonH = buttonW;
        UIButton * delButton = [[UIButton alloc]initWithFrame:CGRectMake(viewW-buttonW, view.frame.size.height-buttonH, buttonW, buttonH)];
        [delButton setImage:[UIImage imageNamed:@"s_del"] forState:UIControlStateNormal];
        [delButton setImage:[UIImage imageNamed:@"s_del"] forState:UIControlStateNormal];
        [view addSubview:delButton];
        [view addSubview:textLabel];
    }
    UIView * lastView = [scroll viewWithTag:labelView_Tag+14];
    scroll.contentSize = CGSizeMake(viewW, lastView.frame.origin.y+lastView.frame.size.height);
    
}
#pragma mark -- 客户信息竖屏适配
-(void)loadUIForCustomerNewsForVertical:(PlaceOrderModel*)model
{
    for (UIView * view in _backView.subviews) {
        [view removeFromSuperview];
    }
    CGFloat jianGeW = 20;
    CGFloat jianGeH = 20;
    CGFloat b_viewH = _backView.frame.size.height;
    CGFloat b_viewW = _backView.frame.size.width;
    CGFloat viewW = (b_viewW-jianGeW*3)/2.0;
    CGFloat viewH = (b_viewH-7*3-jianGeH)/6.0;
    CGFloat labelH = 30;
    CGFloat imageW = 15;
    CGFloat imageH = imageW;
    NSArray * nameArray = [NSArray arrayWithObjects:@"客户姓名：",@"客户昵称：",@"性别：",@"身高：",@"体重：",@"电话：",@"邮箱：",@"",@"地址：",@"",@"备注：",@"", nil];
    NSArray * valueArray = [NSArray arrayWithObjects:@"客户姓名：value",@"客户昵称：value",@"性别：value",@"身高：value",@"体重：value",@"电话：value",@"邮箱：value",@"",@"地址：value",@"",@"备注：value",@"", nil];;
    NSMutableArray * needArr = [[NSMutableArray alloc]init];
    for (int i=0; i<nameArray.count; i++) {
        PlaceOrderTypeModel * l_model = [[PlaceOrderTypeModel alloc]init];
        l_model.name = [nameArray objectAtIndex:i];
        l_model.value = [valueArray objectAtIndex:i];
        
        if (i==2) {
            l_model.selectArr = [[NSMutableArray alloc]init];
            for (int k = 0; k<2; k++) {
                TypeModel* t_model = [[TypeModel alloc]init];
                if (k == 0) {
                    t_model.name = @"男";
                }else{
                    t_model.name = @"女";
                }
                
                [l_model.selectArr addObject:t_model];
            }
            l_model.needSelect = YES;
            l_model.chooseType = PickerChooseTypeForSex;
        }else{
            l_model.needSelect = NO;
        }
        
        [needArr addObject:l_model];
        _needArray  = [NSArray arrayWithArray:needArr];
    }
    for (int i=0; i<needArr.count; i++) {
        PlaceOrderTypeModel * n_model = [needArr objectAtIndex:i];
        int k = i/2;
        int j = i%2;
        UIView * view = [[UIView alloc]init];
        view.tag = View_Tag+i;
        if (i==6 || i==8 || i==10) {
            viewW = b_viewW-jianGeW*3;
            view.frame = CGRectMake(jianGeW, (viewH+5)*k, viewW, viewH);
        }else{
            viewW = (b_viewW-jianGeW*2)/2.0;
            view.frame = CGRectMake(jianGeW+(viewW+jianGeW)*j, (viewH+5)*k, viewW, viewH);
        }
        
        UILabel * label = [[UILabel alloc]init];
        label.text = n_model.name;
        label.textColor = ZhongZi_Color;
        label.font = Cell_Medium_Font;
        [label sizeToFit];
        label.frame = CGRectMake(0, (viewH-labelH)/2.0, label.frame.size.width, labelH);
        [view addSubview:label];
        if (n_model.needSelect) {
            imageW = 15;
            UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(viewW-imageW, (viewH-imageH)/2.0, imageW, imageH)];
            image.image = [UIImage imageNamed:@"ytj_xiaBiao"];
            [view addSubview:image];
        }else if (i == 3 || i==4){
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(viewW-imageW, (viewH-imageH)/2.0, imageW, imageH)];
            if (i==3) {
                label.text = @"cm";
            }else{
                label.text = @"kg";
            }
            
            label.textColor = QianZi_color;
            label.font = Cell_Little_Font;
            [label sizeToFit];
            label.frame = CGRectMake(viewW-label.frame.size.width, (viewH-imageH)/2.0, label.frame.size.width, imageH);
            [view addSubview:label];
            imageW = label.frame.size.width;
        }else{
            imageW = 0;
        }
        
        UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width, (viewH-labelH)/2.0, viewW-(label.frame.origin.x+label.frame.size.width)-imageW-5, labelH)];
        text.userInteractionEnabled = YES;
        text.text = n_model.value;
        text.textAlignment = NSTextAlignmentRight;
        text.textColor = ShenZi_Color;
        text.font = Cell_Medium_Font;
        text.returnKeyType = UIReturnKeyNext;
        text.tag = Text_Tag+_type*10+i;
        [view addSubview:text];
        if (n_model.needSelect) {
            text.userInteractionEnabled = NO;
            text.tag = ChooseText_Tag+n_model.chooseType;
            UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width, (viewH-labelH)/2.0, viewW-(label.frame.origin.x+label.frame.size.width), labelH)];
            button.tag = ChooseButton_Tag+n_model.chooseType;
            [button addTarget:self action:@selector(selectFunc:) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:button];
        }
        if (i==6 || i==8 || i==10) {
            i++;
        }
        UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, viewH-1, viewW, 1)];
        lineView.backgroundColor = Line_color;
        [view addSubview:lineView];
        [_backView addSubview:view];
        
    }
}
#pragma mark -- 客户信息
-(void)loadUIForCustomerNews:(PlaceOrderModel*)model
{
    for (UIView * view in _backView.subviews) {
        [view removeFromSuperview];
    }
    CGFloat jianGeW = 20;
    CGFloat jianGeH = 20;
    CGFloat b_viewH = _backView.frame.size.height;
    CGFloat b_viewW = _backView.frame.size.width;
    CGFloat viewW = (b_viewW-jianGeW*4)/3.0;
    CGFloat viewH = (b_viewH-5*3-jianGeH)/4.0;
    CGFloat labelH = 30;
    CGFloat imageW = 15;
    CGFloat imageH = imageW;
    NSArray * nameArray = [NSArray arrayWithObjects:@"客户姓名：",@"客户昵称：",@"性别：",@"身高：",@"体重：",@"电话：",@"邮箱：",@"地址：",@"",@"备注：",@"",@"", nil];
    NSArray * valueArray = [NSArray arrayWithObjects:@"客户姓名：value",@"客户昵称：value",@"性别：value",@"身高：value",@"体重：value",@"电话：value",@"邮箱：value",@"地址：value",@"",@"备注：value",@"",@"", nil];;
    NSMutableArray * needArr = [[NSMutableArray alloc]init];
    for (int i=0; i<nameArray.count; i++) {
        PlaceOrderTypeModel * l_model = [[PlaceOrderTypeModel alloc]init];
        l_model.name = [nameArray objectAtIndex:i];
        l_model.value = [valueArray objectAtIndex:i];
        
        if (i==2) {
            l_model.selectArr = [[NSMutableArray alloc]init];
            for (int k = 0; k<2; k++) {
                TypeModel* t_model = [[TypeModel alloc]init];
                if (k == 0) {
                    t_model.name = @"男";
                }else{
                    t_model.name = @"女";
                }
                
                [l_model.selectArr addObject:t_model];
            }
            l_model.needSelect = YES;
            l_model.chooseType = PickerChooseTypeForSex;
        }else{
            l_model.needSelect = NO;
        }
        
        [needArr addObject:l_model];
        _needArray  = [NSArray arrayWithArray:needArr];
    }
    for (int i=0; i<12; i++) {
        PlaceOrderTypeModel * n_model = [needArr objectAtIndex:i];
        int k = i/3;
        int j = i%3;
        UIView * view = [[UIView alloc]init];
        view.tag = View_Tag+i;
        if (i==7) {
            viewW = b_viewW-jianGeW*3-viewW;
            view.frame = CGRectMake(jianGeW+((b_viewW-jianGeW*4)/3.0+jianGeW)*j, (viewH+5)*k, viewW, viewH);
        }else if(i==9){
            viewW = b_viewW-jianGeW*2;
            view.frame = CGRectMake(jianGeW+(viewW+jianGeW)*j, (viewH+5)*k, viewW, viewH);
        }else{
            viewW = (b_viewW-jianGeW*4)/3.0;
            view.frame = CGRectMake(jianGeW+(viewW+jianGeW)*j, (viewH+5)*k, viewW, viewH);
        }
        
        UILabel * label = [[UILabel alloc]init];
        label.text = n_model.name;
        label.textColor = ZhongZi_Color;
        label.font = Cell_Medium_Font;
        [label sizeToFit];
        label.frame = CGRectMake(0, (viewH-labelH)/2.0, label.frame.size.width, labelH);
        [view addSubview:label];
        if (n_model.needSelect) {
            imageW = 15;
            UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(viewW-imageW, (viewH-imageH)/2.0, imageW, imageH)];
            image.image = [UIImage imageNamed:@"ytj_xiaBiao"];
            [view addSubview:image];
        }else if (i == 3 || i==4){
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(viewW-imageW, (viewH-imageH)/2.0, imageW, imageH)];
            if (i==3) {
                label.text = @"cm";
            }else{
                label.text = @"kg";
            }
            
            label.textColor = QianZi_color;
            label.font = Cell_Little_Font;
            [label sizeToFit];
            label.frame = CGRectMake(viewW-label.frame.size.width, (viewH-imageH)/2.0, label.frame.size.width, imageH);
            [view addSubview:label];
            imageW = label.frame.size.width;
        }else{
            imageW = 0;
        }
        
        UITextField * text = [[UITextField alloc]initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width, (viewH-labelH)/2.0, viewW-(label.frame.origin.x+label.frame.size.width)-imageW-5, labelH)];
        text.userInteractionEnabled = YES;
        text.text = n_model.value;
        text.textAlignment = NSTextAlignmentRight;
        text.textColor = ShenZi_Color;
        text.font = Cell_Medium_Font;
        text.returnKeyType = UIReturnKeyNext;
        text.tag = Text_Tag+_type*10+i;
        [view addSubview:text];
        if (n_model.needSelect) {
            text.userInteractionEnabled = NO;
            text.tag = ChooseText_Tag+n_model.chooseType;
            UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width, (viewH-labelH)/2.0, viewW-(label.frame.origin.x+label.frame.size.width), labelH)];
            button.tag = ChooseButton_Tag+n_model.chooseType;
            [button addTarget:self action:@selector(selectFunc:) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:button];
        }
        if (i==7) {
            i++;
        }else if(i==9){
            i = i+2;
        }
        UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, viewH-1, viewW, 1)];
        lineView.backgroundColor = Line_color;
        [view addSubview:lineView];
        [_backView addSubview:view];
        
    }
}

#define Amount_HeadButtonTag 406000
#define Amount_LabelTag 407000
#pragma mark -- 量体信息
-(void)loadAmountViewForHeadView:(UIView*)headView
{
    CGFloat buttonW = 100;
    NSArray * nameArray = [NSArray arrayWithObjects:@"净体量体",@"成衣尺寸",@"标准号加减",nil];
    for (int i=0; i<nameArray.count; i++) {
        UIButton * h_button = [[UIButton alloc]initWithFrame:CGRectMake(buttonW*i, 0, buttonW, 35)];
        [h_button setTitleColor:ZhongZi_Color forState:UIControlStateNormal];
        h_button.titleLabel.font = Cell_Medium_Font;
        [h_button setTitle:[nameArray objectAtIndex:i] forState:UIControlStateNormal];
        h_button.tag = Amount_HeadButtonTag+i;
        [h_button addTarget:self action:@selector(amountForHeadButtonFunc:) forControlEvents:UIControlEventTouchUpInside];
        [headView addSubview:h_button];
        
    }
}

-(void)loadAmountViewForFuDongView:(UIView *)h_image
{
    CGFloat imageW = 348;
    CGFloat imageH = 182;
    CGFloat d_imageW = 226;
    CGFloat d_imageH = 277;
    CGFloat jianGeW = 20;
    CGFloat jianGeH = 20;
    _floatView = [[CustomSketchMapTableView alloc]init];
    [_backView addSubview:_floatView];
    [_backView bringSubviewToFront:_floatView];
    _floatView.hasInfo = NO;
    [_floatView loadViewForSketchMap];
    [_floatView mas_remakeConstraints:^(MASConstraintMaker *make) {
        layoutViews(^{
            make.left.equalTo(@(jianGeW+20));
            make.top.equalTo(@(h_image.frame.origin.y+h_image.frame.size.height+20));
            make.width.equalTo(@(d_imageW));
            make.bottom.equalTo(_backView).offset(-40);
        }, ^{
            make.left.equalTo(@(jianGeW));
            make.top.equalTo(@(-40));
            make.width.equalTo(@(d_imageW));
            make.height.equalTo(@(d_imageH));
        });
        
    }];
}

-(void)hiddenFloatView
{
    _floatView.hidden = YES;
}

-(void)ShowFloatView
{
    _floatView.hidden = NO;
}

#define TetiButton_Tag 410000
#define TetiView_Tag 420000

#define StyleButton_Tag 430000
#define StyleView_Tag 440000
#pragma mark -- 量体信息
-(void)loadUIForAmountNews:(PlaceOrderModel*)model
{
    [PlaceOrderViewController blockForFloatView:^(BOOL isShow) {
        layoutViews(^{
            
        }, ^{
            if (isShow) {
                [self ShowFloatView];
            }else{
                [self hiddenFloatView];
            }
        });
        
    }];
    
    
    for (UIView * view in _backView.subviews) {
        [view removeFromSuperview];
    }
    CGFloat jianGeW = 20;
    CGFloat jianGeH = 20;
    CGFloat b_viewH = _backView.frame.size.height;
    CGFloat b_viewW = _backView.frame.size.width;
    //    CGFloat viewW = b_viewW-jianGeW*2;
    //    CGFloat viewH = b_viewH-jianGeH*2;
    CGFloat headViewH = 40;
    CGFloat buttonW = 100;
    CGFloat b_jianGeW = (b_viewW-buttonW*3)/2.0;
    UIView * headView = [[UIView alloc]initWithFrame:CGRectMake(b_jianGeW, 0, buttonW*3, headViewH)];
    [self loadAmountViewForHeadView:headView];
    
    CGFloat labelW = 60;
    CGFloat labelH = 2;
    UIButton * tmpButton = [headView viewWithTag:Amount_HeadButtonTag+_needTag];
    [tmpButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    UILabel * h_label = [[UILabel alloc]initWithFrame:CGRectMake(tmpButton.frame.origin.x+(tmpButton.frame.size.width-labelW)/2.0, headViewH-labelH, labelW, labelH)];
    h_label.tag = Amount_LabelTag;
    h_label.backgroundColor = [UIColor redColor];
    [headView addSubview:h_label];
    UIView *h_lineView = [[UIView alloc]initWithFrame:CGRectMake(0, headViewH, b_viewW, 1)];
    h_lineView.backgroundColor = Line_color;
    [_backView addSubview:h_lineView];
    [_backView addSubview:headView];
    CGFloat h_imageW = 105;
    CGFloat h_imageH = 80;
    CGFloat l_viewW = 300;
    UIImageView * h_image = [[UIImageView alloc]initWithFrame:CGRectMake((l_viewW-h_imageW)/2.0, h_lineView.frame.origin.y+h_lineView.frame.size.height+20, h_imageW, h_imageH)];
    h_image.image = [UIImage imageNamed:@"s_yifuRight"];
    layoutViews(^{
        h_image.frame = CGRectMake((l_viewW-h_imageW)/2.0, h_lineView.frame.origin.y+h_lineView.frame.size.height+20, h_imageW, h_imageH);
    }, ^{
        h_image.frame = CGRectMake(b_viewW-jianGeW-h_imageW, -h_imageH/2.0, h_imageW, h_imageH);
    });
    [_backView addSubview:h_image];
    
    
    __block CGFloat s_jianGeW = 0;
    layoutViews(^{
        s_jianGeW = headView.frame.origin.x;
    }, ^{
        s_jianGeW = jianGeW;
    });
    UIScrollView * scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(s_jianGeW, h_lineView.frame.origin.y+h_lineView.frame.size.height+5, b_viewW-s_jianGeW, b_viewH-(h_lineView.frame.origin.y+h_lineView.frame.size.height+5))];
    [_backView addSubview:scrollView];
    [self loadAmountViewForFuDongView:h_image];
    UIView * standardView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, b_viewW-s_jianGeW, 0)];
    if (_needTag == 2) {
        standardView.frame = CGRectMake(0, 0, b_viewW-s_jianGeW, 240);
        [self loadStandardViewForAmountNews:standardView];
    }
    
    [scrollView addSubview:standardView];
    UIView * numberView = [[UIView alloc]initWithFrame:CGRectMake(0, standardView.frame.origin.y+standardView.frame.size.height-15,  b_viewW-s_jianGeW, 0)];
    [scrollView addSubview:numberView];
    if (_needTag == 2) {
        numberView.frame = CGRectMake(0, standardView.frame.origin.y+standardView.frame.size.height-15,  b_viewW-s_jianGeW, 230);
        [self loadNUmberViewForAmountNews:numberView];
    }
    CustomRulerNewsView * rulerView = [[CustomRulerNewsView alloc]initWithFrame:CGRectMake(0, numberView.frame.origin.y+numberView.frame.size.height+5, b_viewW-s_jianGeW, 200)];
//    UIView * rulerView = [[UIView alloc]initWithFrame:CGRectMake(0, numberView.frame.origin.y+numberView.frame.size.height+5, b_viewW-headView.frame.origin.x, 200)];
    [self loadRulerUIForAmountNews:rulerView];
    [scrollView addSubview:rulerView];
    CGFloat l_imageH = 20;
    UIImageView *s_image = [[UIImageView alloc]initWithFrame:CGRectMake(0, rulerView.frame.origin.y+rulerView.frame.size.height+5, b_viewW-s_jianGeW, l_imageH)];
    s_image.image = [UIImage imageNamed:@"o_jiandao"];
    [scrollView addSubview:s_image];
    UIView * tetiView = [[UIView alloc]initWithFrame:CGRectMake(0, s_image.frame.origin.y+s_image.frame.size.height+15, b_viewW-s_jianGeW, 300)];
    CGFloat td_imageW = 15;
    CGFloat td_imageH = td_imageW;
    UIView *t_dianView = [[UIView alloc]initWithFrame:CGRectMake(0, (Nomal_Label_H-td_imageH)/2.0, td_imageW, td_imageH)];
    
    [t_dianView setYuanJiaoForRadius:3.0 andMasks:NO];
    t_dianView.backgroundColor = RGBColorAlpha(44, 44, 44, 1);
    [tetiView addSubview:t_dianView];
    
    UILabel * t_titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(t_dianView.frame.origin.x+t_dianView.frame.size.width+5, 0, 100, Nomal_Label_H)];
    t_titleLabel.text = @"特体信息";
    t_titleLabel.textColor = ZhongZi_Color;
    t_titleLabel.font = Cell_Medium_Font;
    [tetiView addSubview:t_titleLabel];
    SpecialView * t_newsView = [[SpecialView alloc]initWithFrame:CGRectMake(0, Nomal_Label_H, b_viewW-s_jianGeW, 200)];
//    UIView * t_newsView = [[UIView alloc]initWithFrame:CGRectMake(0, Nomal_Label_H, b_viewW-headView.frame.origin.x, 200)];
//    [self loadTetiViewForAmountNews:t_newsView];
    NSArray * nameArray = @[@"人体形态",@"左肩",@"右肩",@"肚型",@"手臂",@"臂型",@"背型"];
    t_newsView.modelArray = [NSMutableArray arrayWithArray:nameArray];
    t_newsView.Button_Tag = TetiButton_Tag;
    t_newsView.View_Tag = TetiView_Tag;
    [t_newsView loadUI];
    tetiView.frame = CGRectMake(0, s_image.frame.origin.y+s_image.frame.size.height+15, b_viewW-s_jianGeW, t_newsView.frame.origin.y+t_newsView.frame.size.height);
    [tetiView addSubview:t_newsView];
    [scrollView addSubview:tetiView];
    
    UIView * styleView = [[UIView alloc]initWithFrame:CGRectMake(0, tetiView.frame.origin.y+tetiView.frame.size.height+15, b_viewW-s_jianGeW, 300)];
    UIView *s_dianView = [[UIView alloc]initWithFrame:CGRectMake(0, (Nomal_Label_H-td_imageH)/2.0, td_imageW, td_imageH)];
    [s_dianView setYuanJiaoForRadius:3.0 andMasks:NO];
    
    s_dianView.backgroundColor = RGBColorAlpha(44, 44, 44, 1);
    [styleView addSubview:s_dianView];
    
    UILabel * s_titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(s_dianView.frame.origin.x+s_dianView.frame.size.width+5, 0, 100, Nomal_Label_H)];
    s_titleLabel.text = @"着装风格";
    s_titleLabel.textColor = ZhongZi_Color;
    s_titleLabel.font = Cell_Medium_Font;
    [styleView addSubview:s_titleLabel];
    SpecialView * s_newsView = [[SpecialView alloc]initWithFrame:CGRectMake(0, Nomal_Label_H, b_viewW-s_jianGeW, 200)];
    
//    [self loadStyleViewForAmountNews:s_newsView];
    nameArray = @[@"西服",@"西裤"];
    s_newsView.modelArray = [NSMutableArray arrayWithArray:nameArray];
    s_newsView.Button_Tag = StyleButton_Tag;
    s_newsView.View_Tag = StyleView_Tag;
    [s_newsView loadUI];
    styleView.frame = CGRectMake(0, tetiView.frame.origin.y+tetiView.frame.size.height+15, b_viewW-s_jianGeW, s_newsView.frame.origin.y+s_newsView.frame.size.height);
    [styleView addSubview:s_newsView];
    [scrollView addSubview:styleView];
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.contentSize = CGSizeMake(b_viewW-s_jianGeW, styleView.frame.origin.y+styleView.frame.size.height);
    
    
}

#define StandardButton_Tag 409000
#define StandardView_Tag 409100
-(void)loadStandardViewForAmountNews:(UIView*)tmpView
{
    for (UIView * view in tmpView.subviews) {
        [view removeFromSuperview];
    }
    CGFloat viewW = tmpView.frame.size.width;
    CGFloat viewH = tmpView.frame.size.height;
    UILabel * s_titleLabel = [[UILabel alloc]init];
    s_titleLabel.text = @"量体单位与客户信息单位一致";
    s_titleLabel.textColor = QianZi_color;
    s_titleLabel.font = Cell_Medium_Font;
    [s_titleLabel sizeToFit];
    s_titleLabel.frame = CGRectMake(viewW-s_titleLabel.frame.size.width, 0, s_titleLabel.frame.size.width, 30);
    [tmpView addSubview:s_titleLabel];
    CGFloat top = 20; // 顶端盖高度
    CGFloat bottom = 60 ; // 底端盖高度
    CGFloat left = 20; // 左端盖宽度
    CGFloat right = 20; // 右端盖宽度
    
    UIImage * image = [UIImage imageNamed:@"o_shang"];
    // 指定为拉伸模式，伸缩后重新赋值
    image = [image stretchImageWithInsetsTop:top left:left bottom:bottom right:right];
    UIImageView *backImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 30, viewW, viewH-30)];
    [tmpView addSubview:backImage];
    backImage.image = image;
    CGFloat jianGeW = 4;
    CGFloat jianGeH = 4;
    UIView * backView = [[UIView alloc]initWithFrame:CGRectMake(jianGeW, jianGeH, viewW-jianGeW*2, viewH-jianGeH-bottom+5)];
    
    [backView setYuanJiaoForRadius:8.0 andMasks:YES];
    
    CGFloat b_viewW =  viewW-jianGeW*2;
    CGFloat b_viewH =  viewH-jianGeH-bottom+5;
    CGFloat buttonW = b_viewW/6.0;
    CGFloat buttonH = b_viewH/4.0;
    CGFloat jianGe = 10;
    NSArray * nameArr = [NSArray arrayWithObjects:@"MTM标准号",@"欧码",@"英美码",@"亚码",@"客户指定号型",@"亚码客户指定户型",@"MTM标准号",@"欧码",@"英美码",@"亚码",@"客户指定号型",@"亚码客户指定户型", nil];
    _model.childArr = [NSArray arrayWithArray:nameArr];
    for (int i=0; i<nameArr.count; i++) {
        int k = i/6;
        int j = i%6;
        
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(buttonW*j, buttonH*k, buttonW, buttonH)];
        view.tag = StandardView_Tag+i;
        UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(jianGe, jianGe, buttonW-jianGe*2, buttonH-jianGe*2)];
        [button setTitle:[nameArr objectAtIndex:i] forState:UIControlStateNormal];
        button.tag = StandardButton_Tag+i;
        button.titleLabel.numberOfLines = 0;
        button.titleLabel.font = Cell_Medium_Font;
        [button setTitleColor:ZhongZi_Color forState:UIControlStateNormal];
        [button addTarget:self action:@selector(standardButtonFunc:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:button];
        [backView addSubview:view];
    }
    UIView * l_view = [backView viewWithTag:StandardView_Tag+nameArr.count-1];
    backView.frame = CGRectMake(jianGeW, jianGeH, backView.frame.size.width, l_view.frame.origin.y+l_view.frame.size.height);
    backImage.frame = CGRectMake(0, 30, backImage.frame.size.width, backView.frame.origin.y+backView.frame.size.height+(jianGeH+bottom-10-30));
    UIView * view = [backView viewWithTag:StandardView_Tag];
    view.backgroundColor = RGBColorAlpha(255, 66, 89, 1);
    UIButton * button = [backView viewWithTag:StandardButton_Tag];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    backImage.userInteractionEnabled = YES;
    [backImage addSubview:backView];
    tmpView.frame = CGRectMake(0, 0, tmpView.frame.size.width, backImage.frame.size.height+backImage.frame.origin.y);
}

#define NUmberButton_Tag 409300
#define NUmberView_Tag 409200
-(void)loadNUmberViewForAmountNews:(UIView*)tmpView
{
    for (UIView * view in tmpView.subviews) {
        [view removeFromSuperview];
    }
    CGFloat top = 60; // 顶端盖高度
    CGFloat bottom = 20 ; // 底端盖高度
    CGFloat left = 20; // 左端盖宽度
    CGFloat right = 20; // 右端盖宽度
    CGFloat viewW = tmpView.frame.size.width;
    CGFloat viewH = tmpView.frame.size.height;
   
    UIImage * image = [UIImage imageNamed:@"o_xia"];
    // 指定为拉伸模式，伸缩后重新赋值
    image = [image stretchImageWithInsetsTop:top left:left bottom:bottom right:right];
    UIImageView *backImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, viewW, viewH)];
    [tmpView addSubview:backImage];
    backImage.image = image;
    CGFloat jianGeW = 4;
    CGFloat jianGeH = 4;
    UIView * backView = [[UIView alloc]initWithFrame:CGRectMake(jianGeW, top-40, viewW-jianGeW*2, viewH-jianGeH-20)];
    [backView setYuanJiaoForRadius:8.0 andMasks:YES];
    
    CGFloat b_viewW =  viewW-jianGeW*2;
    CGFloat b_viewH =  viewH-jianGeH-20;
    CGFloat buttonW = b_viewW/6.0;
    CGFloat buttonH = b_viewH/4.0;
    CGFloat jianGe = 10;
    NSArray * nameArr = [NSArray arrayWithObjects:@"160/80",@"160/80",@"160/80",@"160/80",@"160/80",@"160/80",@"160/80",@"160/80",@"160/80",@"160/80",@"160/80",@"160/80",@"160/80", nil];
    _model.childArr = [NSArray arrayWithArray:nameArr];
    for (int i=0; i<nameArr.count; i++) {
        int k = i/6;
        int j = i%6;
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(buttonW*j, buttonH*k, buttonW, buttonH)];
        view.tag = NUmberView_Tag+i;
        UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(jianGe, jianGe, buttonW-jianGe*2, buttonH-jianGe*2)];
        [button setTitle:[nameArr objectAtIndex:i] forState:UIControlStateNormal];
        button.tag = NUmberButton_Tag+i;
        button.titleLabel.numberOfLines = 0;
        button.titleLabel.font = Cell_Medium_Font;
        [button addTarget:self action:@selector(numberButtonFunc:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitleColor:ZhongZi_Color forState:UIControlStateNormal];
        [view addSubview:button];
        [backView addSubview:view];
    }
    UIView * l_view = [backView viewWithTag:NUmberView_Tag+nameArr.count-1];
    backView.frame = CGRectMake(jianGeW, top-40, backView.frame.size.width, l_view.frame.origin.y+l_view.frame.size.height);
    backImage.frame = CGRectMake(0, 0, backImage.frame.size.width, backView.frame.origin.y+backView.frame.size.height+(jianGeH));
    UIView * view = [backView viewWithTag:NUmberView_Tag+6];
    view.backgroundColor = RGBColorAlpha(255, 66, 89, 1);
    UIButton * button = [backView viewWithTag:NUmberButton_Tag+6];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    backImage.userInteractionEnabled = YES;
    [backImage addSubview:backView];
    tmpView.frame = CGRectMake(0, tmpView.frame.origin.y, tmpView.frame.size.width, backImage.frame.size.height+backImage.frame.origin.y);
}
#define Amount_RulerView_Tag 408000
-(void)loadRulerUIForAmountNews:(UIView*)rulerView
{
    
    
    CGFloat viewW = rulerView.frame.size.width;
    CGFloat viewH = rulerView.frame.size.height;
    
    for (UIView * view in rulerView.subviews) {
        [view removeFromSuperview];
    }
    NSMutableArray * needArr = [[NSMutableArray alloc]init];
    NSArray * nameArr = [NSArray arrayWithObjects:@"胸围：",@"腰围：",@"臀围：",@"颈围：",@"肩宽：", nil];
    NSArray * valueArr = [NSArray arrayWithObjects:@"10",@"40",@"170",@"70",@"60", nil];
    NSArray * unitArr = [NSArray arrayWithObjects:@"cm",@"cm",@"cm",@"cm",@"cm", nil];
    for (int i=0; i<nameArr.count; i++) {
        EssentialModel * model = [[EssentialModel alloc]init];
        model.name = [nameArr objectAtIndex:i];
        model.value = [valueArr objectAtIndex:i];
        model.unit =[unitArr objectAtIndex:i];
        model._id = [NSString stringWithFormat:@"%d",i];
        [needArr addObject:model];
    }
    CGFloat t_viewH = 80;
    
    for (int j=0; j<needArr.count; j++) {
        EssentialModel *model = [needArr objectAtIndex:j];
        model.essentialType = EssentialViewTypeForRulerWithPlaceOrder;
        RulerShowView * view = [[RulerShowView alloc]initWithFrame:CGRectMake(0, t_viewH*j, viewW ,t_viewH)];
        view.rulerCustom.rulerSelectedAction = ^(CGFloat value) {
            [self ShowFloatView];
            view.valueText.text = [NSString stringWithFormat:@"%d",(int)value];
            
        };
        view.tag = View_Tag+j;
        view.tag = Amount_RulerView_Tag+j;
        view.valueText.delegate  =self;
        view.valueText.tag = Text_Tag+_type*10+j;
        view.valueText.keyboardType = UIKeyboardTypeNumberPad;
        [view reloadUI:model];
        if (j%2==1) {
            view.rulerCustom.min = 0;
            view.rulerCustom.max = 280;
            [view.rulerCustom setValue:[model.value intValue] animated:YES];
        }else{
//            view.rulerCustom.rulerType = RulerTypeForWeight;
            view.rulerCustom.min = 0;
            view.rulerCustom.max = 500;
             [view.rulerCustom setValue:[model.value intValue] animated:YES];
        }
        
        [rulerView addSubview:view];
    }
    RulerShowView * View = (RulerShowView*)[rulerView viewWithTag:Amount_RulerView_Tag+needArr.count-1];
    rulerView.frame = CGRectMake(rulerView.frame.origin.x, rulerView.frame.origin.y, viewW, View.frame.origin.y+View.frame.size.height+20);
    
}
#pragma mark -- 按钮手势方法
//工艺信息右添加按钮
-(void)r_buttonFunc:(UIButton*)button
{
    
}
//工艺信息左添加按钮
-(void)l_buttonFunc:(UIButton*)button
{
    
}
//标准号
-(void)standardButtonFunc:(UIButton*)button
{
    int index = (int)button.tag-StandardButton_Tag;
    for (int i=0; i<_model.childArr.count; i++) {
        UIView * tmpView = [_backView viewWithTag:StandardView_Tag+i];
        tmpView.backgroundColor = [UIColor whiteColor];
        UIButton *tmpButton = [_backView viewWithTag:StandardButton_Tag+i];
        [tmpButton setTitleColor:ZhongZi_Color forState:UIControlStateNormal];
    }
    UIView * view = [_backView viewWithTag:StandardView_Tag+index];
    view.backgroundColor = RGBColorAlpha(255, 66, 89, 1);
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
-(void)numberButtonFunc:(UIButton*)button
{
    int index = (int)button.tag-NUmberButton_Tag;
    for (int i=0; i<_model.childArr.count; i++) {
        UIView * tmpView = [_backView viewWithTag:NUmberView_Tag+i];
        tmpView.backgroundColor = [UIColor whiteColor];
        UIButton *tmpButton = [_backView viewWithTag:NUmberButton_Tag+i];
        [tmpButton setTitleColor:ZhongZi_Color forState:UIControlStateNormal];
    }
    UIView * view = [_backView viewWithTag:NUmberView_Tag+index];
    view.backgroundColor = RGBColorAlpha(255, 66, 89, 1);
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
//特体
-(void)styleButtonFunc:(UIButton*)button
{
    int tag = (int)button.tag-StyleButton_Tag;
    int index = tag/100;
    for (int i=0; i<8; i++) {
        UIButton * tmpButton = [_backView viewWithTag:StyleButton_Tag+index*100+i];
        tmpButton.backgroundColor = [UIColor whiteColor];
        [tmpButton setTitleColor:QianZi_color forState:UIControlStateNormal];
    }
    button.backgroundColor = RGBColorAlpha(255, 66, 89, 1);
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
-(void)tetiButtonFunc:(UIButton*)button
{
    int tag = (int)button.tag-TetiButton_Tag;
    int index = tag/100;
    for (int i=0; i<8; i++) {
        UIButton * tmpButton = [_backView viewWithTag:TetiButton_Tag+index*100+i];
        tmpButton.backgroundColor = [UIColor whiteColor];
        [tmpButton setTitleColor:QianZi_color forState:UIControlStateNormal];
    }
    button.backgroundColor = RGBColorAlpha(255, 66, 89, 1);
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
-(void)selectFunc:(UIButton*)button
{
     int needTag = (int)button.tag-ChooseButton_Tag;
    for (PlaceOrderTypeModel* model in _needArray) {
        if (model.chooseType == needTag) {
            _typeModel = model;
        }
    }
    if (_selectBlock) {
        _selectBlock(_typeModel);
    }
}
-(void)amountForHeadButtonFunc:(UIButton*)button
{
    UILabel * label = [_backView viewWithTag:Amount_LabelTag];
    CGFloat labelW = 60;
    CGFloat labelH = 2;
    [UIView animateWithDuration:0.37 animations:^{
         label.frame =CGRectMake(button.frame.origin.x+(button.frame.size.width-labelW)/2.0, label.frame.origin.y, labelW, labelH);
    }];
   
    for (int i=0; i<3; i++) {
        UIButton * tmpButton = [_backView viewWithTag:Amount_HeadButtonTag+i];
        [tmpButton setTitleColor:ZhongZi_Color forState:UIControlStateNormal];
    }
    [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    _needTag = (int)button.tag-Amount_HeadButtonTag;
    [self loadUIForAmountNews:_model];
}


#pragma mark - 标尺代理方法
- (void)rulerWith:(NSInteger)days  andRulerType:(RulerType)_rulerType andView:(UIView *)view{
    RulerShowView * tmpView = (RulerShowView*)view.superview;
    
    tmpView.valueText.text = [NSString stringWithFormat:@"%f",days];
}

- (void)rulerRunEnd {
    NSLog(@"end");
}

#pragma mark - textFeildDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    int index = (int)textField.tag-Text_Tag;
    if (textField.becomeFirstResponder) {
        UITextField * text = [self viewWithTag:Text_Tag+index+1];
        [textField resignFirstResponder];
        [text becomeFirstResponder];
    }
    return YES;
}
-(void)textFieldDidEndEditing:(UITextField *)textField
{
    if (textField.tag == L_textTag) {
        if (_textBlock) {
            _textBlock(textField.text,NO);
        }
    }
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if (textField.tag == L_textTag) {
        if (_textBlock) {
            _textBlock(textField.text,YES);
        }
    }
    return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

{
    
    return YES;
    
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    
}

-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    
    return YES;
}



#pragma mark -- Block
static SelectButtonBlock _selectBlock;
+(void)blockForSelectButton:(SelectButtonBlock)selectBlock
{
    _selectBlock  = selectBlock;
}
static GYTextBlock _textBlock;
+(void)blockForGYText:(GYTextBlock)textBlock
{
    _textBlock = textBlock;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
@end
